package cn.outsourcing.supermarket.provider;

import org.apache.ibatis.jdbc.SQL;

/**
 * 后台订单构造器
 *
 * @author gzkemays
 * @since 2021/11/3 2:34
 */
public class BackstageOrderProvider {
  public String getOrderDetails() {
    return new SQL() {
      {
        SELECT("ho.*", "hu.nickname as username", "hu.avatar")
            .FROM("hiolabs_order ho")
            .LEFT_OUTER_JOIN("hiolabs_user hu ON hu.id = ho.user_id")
            .WHERE("ho.id = ${orderId}");
      }
    }.toString();
  }

  public String getOrderGoodsDetails() {
    return new SQL() {
      {
        SELECT("*")
            .FROM("hiolabs_order_goods hog")
            .LEFT_OUTER_JOIN("hiolabs_product hp on hp.id = hog.product_id")
            .WHERE("hog.order_id = ${orderId} and hog.is_delete = 0");
      }
    }.toString();
  }
}
